<template>
  <div>
    <n-spin :show="loading" description="请稍候...">
      <n-drawer v-model:show="showModal" :width="dialogWidth">
        <n-drawer-content>
          <template #header> 生成演示详情 </template>
          <template #footer>
            <n-button @click="showModal = false"> 关闭 </n-button>
          </template>
          <n-descriptions label-placement="left" class="py-2" column="1">
                <n-descriptions-item>
          <template #label>code</template>
          <span v-html="formValue.code"></span></n-descriptions-item>

        <n-descriptions-item>
          <template #label>name</template>
          <span v-html="formValue.name"></span></n-descriptions-item>

        <n-descriptions-item>
          <template #label>日期</template>
          <span v-html="formValue.date"></span></n-descriptions-item>

        <n-descriptions-item>
          <template #label>炸板次数</template>
          {{ formValue.zbcs }}
        </n-descriptions-item>

        <n-descriptions-item>
          <template #label>连板次数
</template>
          {{ formValue.lbNumber }}
        </n-descriptions-item>

        <n-descriptions-item>
          <template #label>涨停统计-天数范围</template>
          {{ formValue.ztStatisticsDays }}
        </n-descriptions-item>

        <n-descriptions-item>
          <template #label>涨停统计-涨停天数
</template>
          {{ formValue.ztStatisticsNum }}
        </n-descriptions-item>

        <n-descriptions-item>
          <template #label>所属行业</template>
          <span v-html="formValue.industry"></span></n-descriptions-item>

        <n-descriptions-item>
          <template #label>1 强势股 2 次新 3 炸板</template>
          {{ formValue.type }}
        </n-descriptions-item>

        <n-descriptions-item>
          <template #label>是否新高</template>
          {{ formValue.newHigh }}
        </n-descriptions-item>

        <n-descriptions-item>
          <template #label>1 60日新高 2 60日新高且近期多次涨停</template>
          {{ formValue.selectedReason }}
        </n-descriptions-item>


          </n-descriptions>
        </n-drawer-content>
      </n-drawer>
    </n-spin>
  </div>
</template>

<script lang="ts" setup>
  import { computed, ref } from 'vue';
  import { useMessage } from 'naive-ui';
  import { View } from '@/api/stockAbnormalPool';
  import { State, newState, options } from './model';
  import { adaModalWidth, getOptionLabel, getOptionTag } from '@/utils/hotgo';
  import { getFileExt } from '@/utils/urlUtils';

  const message = useMessage();
  const dialogWidth = ref('75%');
  const loading = ref(false);
  const showModal = ref(false);
  const formValue = ref(newState(null));
  const fileAvatarCSS = computed(() => {
    return {
      '--n-merged-size': `var(--n-avatar-size-override, 80px)`,
      '--n-font-size': `18px`,
    };
  });

  //下载
  function download(url: string) {
    window.open(url);
  }

  function openModal(state: State) {
    adaModalWidth(dialogWidth, 580);
    showModal.value = true;
    loading.value = true;
    View({ id: state.id })
      .then((res) => {
        formValue.value = res;
      })
      .finally(() => {
        loading.value = false;
      });
  }

  defineExpose({
    openModal,
  });
</script>

<style lang="less" scoped></style>